home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.074 < prev    next >
Encoding:
Text File  |  1992-07-15  |  6.3 KB  |  196 lines  |  [TEXT/GEOL]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. Apple IIgs
  6. #74: Top Ten List Manager Things
  7.  
  8. Revised by: Dave Lyons                                               May 1992
  9. Written by: Jim Mensch                                          November 1989
  10.  
  11. This Technical Note presents a method for speeding up custom List Draw
  12. routines, with sample source code for the APW assembler.
  13.  
  14. CHANGES SINCE NOVEMBER 1989: Added information on memFlag and on shared
  15. rListRef resources, and noted that System 6.0 already checks the clip region
  16. and calls your listDraw routine only when needed.
  17. _____________________________________________________________________________
  18.  
  19.  
  20. TEN--MORE MEMFLAG BITS
  21.  
  22. In each member record, bits 0 and 1 of memFlag indicate whether memPtr is a
  23. pointer, handle, or resource ID.  You don't normally have to worry about
  24. that--a custom listDraw routine is one place that you do.  The complete
  25. definition of memFlag is as follows:
  26.  
  27.       Bit      Description
  28.       ---      --------------
  29.        7       memSelected
  30.        6       memDisabled
  31.        5       memNever (Inactive)
  32.        4-2     reserved--set to zero
  33.        1-0     00 = memPtr is a pointer
  34.                01 = memPtr is a handle
  35.                10 = memPtr is a resource ID (type is rPString or rCString)
  36.                11 = reserved
  37.  
  38.  
  39. NINE--SHARING RLISTREF RESOURCES
  40.  
  41. When listRef is a resource ID, the List Manager calls LoadResource every time
  42. it needs your rListRef resource.  If two or more lists share the same
  43. rListRef, they will get the same handle from LoadResource and will interfere
  44. with each other.
  45.  
  46. To give each list its own copy of your the rListRef resource, load the
  47. resource yourself and use DetachResource.  Then feed the listRef to the List
  48. Manager as a handle.  Repeat the process for each list.
  49.  
  50.  
  51. EIGHT--CUSTOM LISTDRAW ROUTINES AND THE CLIP REGION
  52.  
  53. The custom listDraw routine below speeds up your list when running System
  54. Software earlier than 6.0.  The System 6.0 List Manager already calls your
  55. listDraw routine only for members that will not be completely clipped (but
  56. this is still a good starting point if you're writing a custom listDraw
  57. routine for some other reason).
  58.  
  59. To scroll text, the List Manager calls ScrollRect to scroll the list--then 6.0
  60. redraws the newly-exposed members, and older versions redraw all the visible
  61. members.  On small lists this is fine, but on larger lists it can cause the
  62. redrawing of much data that is already on the screen, which can take time.  If
  63. your application does not require 6.0, you may want to use a custom listDraw
  64. routine like this one.
  65.  
  66. First, we check the current clipRgn  (which the List Manager was kind enough
  67. to shrink down to include only the portion of the list that needs redrawing)
  68. against the passed item rectangle.  If the rectangle is in any way enclosed in
  69. the clipRgn, then the member is redrawn; otherwise the routine simply returns
  70. to the List Manager without drawing.  This sample routine is designed to work
  71. only with Pascal-style strings, but it can be easily modified to use any other
  72. type of string you choose.
  73.  
  74. MyListDraw     Start
  75. ;
  76. ; This routine draws a list member if any part of the member's
  77. ; rectangle is inside the current clipRgn.
  78. ;
  79. ; Note that the Data Bank register is not defined on entry
  80. ; to this routine.  If you use any absolute addressing, you
  81. ; must set B yourself and restore its value before exiting.
  82. ;
  83. top           equ  0
  84. left          equ  top+2
  85. bottom        equ  left+2
  86. right         equ  bottom+2
  87. rgnBounds     equ  2
  88. ;
  89. oldDPage      equ  1
  90. theRTL        equ  oldDPage+2
  91. listHand      equ  theRTL+3
  92. memPtr        equ  listHand+4
  93. theRect       equ  memPtr+4
  94.               using globals
  95.  
  96.               phd
  97.               tsc
  98.               tcd
  99.  
  100.               pha
  101.               pha
  102.               _GetClipHandle
  103.               PullLong listHand
  104.  
  105.               ldy #2
  106.               lda [listhand],y
  107.               tax
  108.               lda [listhand]
  109.               sta listhand
  110.               stx listhand+2
  111.  
  112.               lda [therect]                ; now test the top
  113.               dec a                        ; adjust and give a little slack
  114.               ldy #rgnbounds+bottom
  115.               cmp [listhand],y             ; rgnRectBottom>=top?
  116.               blt skip2
  117.               brl NoDraw                   ; if not don't draw..
  118. Skip2         ldy #bottom                  ; now see if the bottom is higher
  119. than the top
  120.               inc a                        ; give a little slack
  121.               lda [therect],y
  122.               ldy #rgnBounds+top
  123.               cmp [listhand],y
  124.               blt NoDraw
  125. NoTest        ANOP
  126.  
  127.               PushLong theRect
  128.               _EraseRect             ; erase the old rectangle
  129.  
  130.               ldy #left
  131.               lda [theRect],y
  132.               tax
  133.               ldy #bottom
  134.               lda [theRect],y
  135.               dec a
  136.               phx
  137.               pha
  138.               _MoveTo
  139.               ldy #2
  140.               lda [memptr],y
  141.               pha
  142.               lda [memptr]
  143.               pha
  144.               _DrawString
  145.  
  146.               ldy #4
  147.               lda [memPtr],y
  148.               and #$00C0             ; strip to the 6 and 7 bits
  149.               beq memDrawn           ; if they are both 0 the member is drawn
  150.               cmp #$0080             ; member selected?
  151.               bne noSelect           ; member not selectable
  152.               PushLong theRect
  153.               _InvertRect
  154.               bra memDrawn
  155. ; if we get here the member is disabled
  156. noSelect      PushLong #DimMask
  157.               _SetPenMask
  158.               PushLong theRect
  159.               _EraseRect
  160.               PushLong #NorMask
  161.               _SetPenMask
  162. memDrawn      ANOP
  163.  
  164.  
  165. ; exit here
  166.               pld
  167.               sep #$20
  168.               longa off
  169.               pla
  170.               ply
  171.  
  172.               plx
  173.               plx
  174.               plx
  175.               plx
  176.               plx
  177.               plx
  178.               phy
  179.               pha
  180.               rep #$20
  181.               longa on
  182.               rtl
  183.  
  184. DimMask       dc  i1'$55,$AA,$55,$AA,$55,$AA,$55,$AA'
  185. NorMask       dc  i1'$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF'
  186.               end
  187.  
  188.  
  189. SEVEN THROUGH ONE--RESERVED FOR FUTURE EXPANSION
  190.  
  191.  
  192. Further Reference
  193. _____________________________________________________________________________
  194.  
  195.    o   Apple IIgs Toolbox Reference, Volumes 1 and 3
  196.